package day240426.work.pp;

import day240426.work.pp.Boy;
import day240426.work.pp.Girl1;
import day240426.work.pp.Person;

import java.lang.reflect.Field;

public class Test {
    public static void main(String[] args) {
        Girl1 girl=new Girl1();
        System.out.println(girl.name);
        System.out.println(girl.age);
        System.out.println("==== ==== ====");

        Boy boy=new Boy();
        System.out.println(boy.name);
        System.out.println(boy.age);
        System.out.println("==== ==== ====");
        //Boy自己是谁完整包名
        System.out.println(boy.getClass().getName());
        //怎么知道Boy的父类
        System.out.println(boy.getClass().getSuperclass().getName());
        //怎么知道Person的父类
        System.out.println(Person.class.getName());


        Person person=new Person();
        Field[] fields=person.getClass().getFields();
        System.out.println(fields);
        System.out.println("==== ==== ====");
        System.out.println("fields.length="+fields.length);
        for (int i = 0; i <fields.length ; i++) {
            System.out.println(fields[i]);
        }
        //Object的父类--Object的的返回值--null，就是“root”
        System.out.println(Object.class.getSuperclass());
        //ToString方法
        System.out.println(boy);
        //behavior也会被父类继承
        boy.eat();
        girl.eat();
        System.out.println("==== ==== ====");
        girl.toString();

    }
}
